//
//  FourViewController.m
//  UI07_UINavigationController
//
//  Created by aaaaaa on 16/6/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "FourViewController.h"
#import "FiveViewController.h"

@interface FourViewController ()

@end

@implementation FourViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"Four";
    
    /**控制导航栏透明度的属性，赋值为No的时候影响了原点**/
    self.navigationController.navigationBar.translucent = NO;
    
    [self createBackSecondButton];
    [self createNextButton];
}

- (void)createBackSecondButton{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(0, 0, 100, 150);
    [button setTitle:@"返回第二页" forState:UIControlStateNormal];
    /*改变button标题的大小*/
    button.titleLabel.font = [UIFont systemFontOfSize:20];
    [self.view addSubview:button];
    button.backgroundColor = [UIColor grayColor];
    [button addTarget:self action:@selector(backSecondAction:) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)backSecondAction:(UIButton *)button{
    
    //返回第二页
    [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
}


- (void)createNextButton{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(100, 100, 100, 100);
    [button setTitle:@"下一页" forState:UIControlStateNormal];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(nextAction:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)nextAction:(UIButton *)button{
    FiveViewController *fiveVc = [[FiveViewController alloc] init];
    
    /**模态到下一页*/
    /*模态出的视图控制器不在导航栏控制器的控制里*/
    [self presentViewController:fiveVc animated:YES completion:^{
        
        
    }];
    [fiveVc release];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
